package com.maple.controller.admin;


import com.maple.result.Result;
import com.maple.service.WorkSpaceService;
import com.maple.vo.BusinessDataVO;
import com.maple.vo.DishOverViewVO;
import com.maple.vo.OrderOverViewVO;
import com.maple.vo.SetmealOverViewVO;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.time.LocalDateTime;
import java.time.LocalTime;

@RestController
@RequestMapping("/admin/workspace")
@Slf4j
public class WorkSpaceController {


    @Autowired
    private WorkSpaceService workSpaceService;


    @GetMapping("/businessData")
    public Result<BusinessDataVO> getTodayBusinessData(){
        log.info("查询今日运营数据{}", LocalDateTime.now());
        //获得当天的开始时间
        LocalDateTime begin = LocalDateTime.now().with(LocalTime.MIN);
        //获得当天的结束时间
        LocalDateTime end = LocalDateTime.now().with(LocalTime.MAX);
        BusinessDataVO businessDataVO = workSpaceService.getTodayBusinessData(begin, end);
        return Result.success();
    }


    @GetMapping("/overviewSetmeals")
    public Result<SetmealOverViewVO> getOverviewSetmeals(){
        log.info("查询套餐总览");
        SetmealOverViewVO setmealOverViewVO = workSpaceService.getOverviewSetmeals();
        return Result.success(setmealOverViewVO);
    }

    @GetMapping("/overviewDishes")
    @ApiOperation("查询菜品总览")
    public Result<DishOverViewVO> dishOverView(){
        return Result.success(workSpaceService.getDishOverView());
    }


    @GetMapping("/overviewOrders")
    public Result<OrderOverViewVO> orderOverView(){
        log.info("查询订单管理数据");
        return Result.success(workSpaceService.getOrderOverView());
    }

}
